import request from '@/utils/request.js';

export default {
	
    getCategoryList(type = null) {
        const params = type ? { type } : {};
        return request.get('/categories/list', {
            params
        });
    },
    
    getCategoryDetail(id) {
        return request.get(`/categories/${id}`);
    },
    
    addCategory(data) {
        return request.post('/categories/add', data);
    },
    
    updateCategory(id, data) {
        return request.put(`/categories/${id}`, data);
    },
    
    deleteCategory(id) {
        return request.delete(`/categories/${id}`);
    },
    

    getCategoryTree() {
        return request.get('/categories/tree');
    },

    getCategoryByType(type) {
        return request.get(`/categories/tree/${type}`);
    }
};